/*
 * @FilePath: /hash-guess-game/src/router/index.ts
 * 介绍:路由文件
 */

import {
  createRouter,
  // createWebHistory,
  createWebHashHistory,
  RouteRecordRaw,
} from "vue-router"; //引入路由
import toast from "@@/components/rework/toast";
import { i18n } from "@@/language";

const modules = import.meta.glob("./module/**.ts", { eager: true });

const routes: Array<RouteRecordRaw> = [];
Object.values(modules).forEach((val: any) => {
  const module: Array<RouteRecordRaw> = val.default;
  routes.push(...module);
});

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

//解析守卫
// router.beforeResolve(async (to) => {
//   return true;
// });

// //前置路由守卫
// router.beforeEach(async (to, from, next) => {
//   //@ts-ignore
//   const { t } = i18n.global;
//   if (to.path === "/") return next({ name: "home" });
//   const whiteList = [""];
//   if (whiteList.includes(to.name as string)) return next();
//   const blacklist = [
//     "safeBox",
//     "drawMoney",
//     "arena",
//     "topUpMoney",
//     "clubMember",
//     "hashRaceCourse",
//     "gameStrategyLucky",
//     "gameStrategyParity",
//     "gameRule",
//     "clubInventory",
//     "meGameList",
//     "bonusList",
//   ];
//   if (blacklist.includes(to.name as string)) {
//     toast.text(t("zan-wei-kai-qi"));
//     return next(from);
//   }
//   next();
// });

export default router;
